package com.ruoyi.web.controller.app.im.util;


import com.ruoyi.web.controller.util.Digests;
import com.ruoyi.web.controller.util.Encodes;

public class SystemUtils {

    public static final int HASH_INTERATIONS = 1024;
    /**
     * 验证密码
     * @param plainPassword 明文密码
     * @param password 密文密码
     * @return 验证成功返回true
     */
    public static boolean validatePassword(String plainPassword, String password) {
        byte[] salt = Encodes.decodeHex(password.substring(0,16));
        byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS);
        return password.equals(Encodes.encodeHex(salt)+Encodes.encodeHex(hashPassword));
    }
}
